package com.acwing.partition19;

import java.io.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author `RKC`
 * @date 2022/4/7 15:48
 */
public class AC1800不做最后一个 {

    private static Map<String, Integer> map = new HashMap<>(7);
    private static Node[] nodes = new Node[7];
    private static int n, idx = 0;

    static {
        map.put("Bessie", 0);
        map.put("Elsie", 0);
        map.put("Daisy", 0);
        map.put("Gertie", 0);
        map.put("Annabelle", 0);
        map.put("Maggie", 0);
        map.put("Henrietta", 0);
    }

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        while (n-- > 0) {
            String[] ss = reader.readLine().split(" ");
            map.put(ss[0], map.get(ss[0]) + Integer.parseInt(ss[1]));
        }
        for (Map.Entry<String, Integer> entry : map.entrySet()) nodes[idx++] = new Node(entry.getKey(), entry.getValue());
        Arrays.sort(nodes);
        String t = null;
        for (int i = 0; i < nodes.length - 1; i++) {
            if (nodes[i].v == nodes[i + 1].v) continue;
            if (i + 2 < nodes.length && nodes[i + 1].v == nodes[i + 2].v) break;
            t = nodes[i + 1].k;
            break;
        }
        if (t == null) writer.write("Tie\n");
        else writer.write(t + "\n");
        writer.flush();
    }

    private static class Node implements Comparable<Node> {
        private String k;
        private int v;

        public Node(String k, int v) {
            this.k = k;
            this.v = v;
        }

        @Override
        public int compareTo(Node o) {
            return v - o.v;
        }
    }
}
